package com.xgx.distqcp.Controller;

import io.jboot.web.controller.JbootController;
import io.jboot.web.controller.annotation.RequestMapping;

import java.sql.*;

@RequestMapping("/oracle")
public class OracleController extends JbootController {
    public void index(){
        ResultSet rs = null;
        Statement stmt = null;
        Connection conn = null;
        try {
            Class.forName("oracle.jdbc.driver.OracleDriver");
            String dbURL = "jdbc:oracle:thin:@//125.222.144.14:1522/orcl";
            conn = DriverManager.getConnection(dbURL, "zfxfzb", "zfsoft_dlkj");
            System.out.println("连接成功");
            stmt=conn.createStatement();
            rs=stmt.executeQuery("select * from yhb where ROWNUM<10");
            while (rs.next()){
                System.out.println(rs.getString("YHM"));
            }

        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            try {
                if (rs != null) {
                    rs.close();
                    rs = null;
                }
                if (stmt != null) {
                    stmt.close();
                    stmt = null;
                }
                if (conn != null) {
                    conn.close();
                    conn = null;
                }
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
        renderCaptcha();

    }
}
